Inheritance at class level:
Which means both Parent and Child are the classes.


OOP's concept: Object Oriented Programming

Java is not 100% OOP's. Bcoz it also supports primitives.
Ex: int, double, boolean, char, float etc

OOPS consist of:

1) Inheritance
2) Polymorphism
3) Encapsulation
4) Abstraction
-----------------------------
Inheritance: It deals about Parent class & Child class relationship in java.
     OR
How the child class inherits the Parent class behaviours

-The parent class is also k.a., Super Class OR Base Class
-The child class is also k.a., Derived class OR Sub class.

EX:
class A{
    
}

class B extends A{
   
}


Types Of Inheritance:

1. Simple Inheritance
2. Multilevel Inheritance
3. Multiple Inheritance
4. Heirarchial Inheritance
5. Hybrid Inheritance


Note:
1. In inheritance child class can inherit all the members of the super class except private, static members

2. final class cannot be inherited. Ex: String, System

3. Child class can inherit parent but parent class canot inherit the child class. (Dependency Inversion Principle)

4. If we create a object to the Child class we can access both Child & Parent class members.

5. If we create a object to Parent class then we can access only parent class members

6. To establish the parent & child class relationship, we need to use extends keyword in child class.
Ex: class Child extends Parent

7. extends keyword allows/supports only 1 parent class. Hence multiple inheritance is not supported at class level

----------------------

1. Simple Inheritance (SI):
   A single child class extends Parent class.

Constructor in SI:
1. If parent class has default constructor it doesnot have impact on child class. Bcoz child class also have default constructor


2: Both parent & Child class are having default constructor. When we create a object to child class which constructor will get execute?
Ans: Both constrcutor will get execute. But Parent default constrcutor will get execute first & followed by child class default constructor.


3: Both parent & Child class are having static block. When we create a object to child class which static block will get execute?
Ans: In simple Inheritance, Both static blocks will get execute. First Parent class static block followed by child class static block.


4. If parent class has Parameterized constructor, then we need to 
   (a) create similar parameterized constructor in child class in order to access the parent class constructor values.
   (b) we need to call parent class constructor inside the child class.
Note: Here calling parent class constructor is mandatory inside the child class constructor


5: Constructor Overloading in Parent class?
Ans: Any one constrcutor of the parent class has to be called inside the child class constructor. But If user wants to call all the Parent class constructors then we need to have multiple construstors inside the child class as well.


6: Constructor Overloading only in Child class?
Ans: No Impact on parent class. Bcoz parent can't inherit the child class behaviours.



7: Method Overloading in SI:
Ans: Method overloading is possible in Independent class & as well as in inheritance (Parent & Child class).


8: Method overriding in SI:
Ans: Method overriding is not possible in independent class. But it is only possible in Inheritance.(Parent & Child class)

Method overriding: Writing the same method in both parent & child classes in which method name, signature & return type are same in both Parent & child class. 
   Here child class method will hide the super class method. Which means when you create a object to the child class & call the method,only child class method will execute by hiding OR overriding super class method.

   Note: Latest implementation will get execute in method overriding.
------------------------------------

2. Multi Level Inheritance (ML):
   A child class (C) extends its parent (B) class and the parent (B) class has its another Parent (A) class.

Q: Both parent & Child class in ML inheritance are having default constructor. When we create a object to child class which constructor will get execute?
Ans: All constrcutor will get execute. But Parent default constrcutor will get execute first & followed by child class default constructors.
Ex: Class A constructor-> class B constructor-> class C constructor


Q: Both parent & Child class in ML inheritance are having static block. When we create a object to child class which static block will get execute?
Ans: In ML Inheritance, all the static blocks will get execute. First Parent class static block followed by child class static block.
Ex: Class A static block-> class B static block-> class C static block


Q: Parameterized Constructor in Parent class?
Ans: Child class needs to have similar parameterized constructor in order to call the parent class parameterized constructor inside the Child class parameterized constructor.


Q: Constructor Overloading in Parent class?
Ans: Any one constrcutor of the parent class has to be called inside the child class constructor. But If user wants to call all the Parent class constructors then we need to have multiple constructors inside the child class as well.


Q: Method Overloading in ML Inheritance:
Ans: Method overloading is possible in Individual class & as well as in inheritance.



Q: Method overriding in ML Inheritance:
Ans: Method overriding is not possible in independent class. But it is only possible in Inheritance.

Method overriding: Writing same method in both parent & child class in which method name, signature & return type are same in both Parent & child class. 
   Here child class method will hide the super class method. Which means when you creat a object to the child class, only child class method will execute by hiding OR overriding super class method.
-------------------------------

3. Multiple Inheritance: It is not supported in java at class & abstract class level due to diamond problem.
  But it is possible in java at interface level. Which means when you use parent as a interface the multiple inheritance is possible.
  
Ex: diamond problem example

Class A has two child classes B and C.
Class D has two parent classes B and C.
methodCommon() of A is overriden by classes B and C.
When you call methodCommon() on instance of D, which method should get overridden (From class B or C)
----------------------------------

4. Hierarchial Inheritance
   (a) default constructor
   (b) parameterized Constructor
   (c) Constructor Overloading
   (d) Method Overloading
   (e) Method Overriding
------------------------
5. Hybrid inheritance.
   (a) default constructor
   (b) parameterized Constructor
   (c) Constructor Overloading
   (d) Method Overloading
   (e) Method Overriding
